﻿@model List<YouWei.Infrastructure.Entity.CommonEnum>
@{
    ViewBag.Title = "用户行为轨迹";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<section class="content-header">
    <h1>
        用户行为轨迹
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active">用户行为轨迹</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <form id="search-form" class="form-inline">
                        <div class="form-group">
                            <label>标识符</label>
                            <input type="text" class="form-control" style="width:100px;" name="TrailIdentity" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <label>浏览类型</label>
                            <select class="form-control" name="TrailType">
                                <option value="-1">全部</option>
                                @foreach (var item in Model)
                                {
                                    if (item.EnumType == "TrailType")
                                    {
                                        <option value="@item.EnumField">@item.EnumDesc</option>
                                    }
                                }
                            </select>
                        </div>
                        <div class="form-group">
                            <label>操作类别</label>
                            <select class="form-control" name="ActionType">
                                <option value="-1">全部</option>
                                @foreach (var item in Model)
                                {
                                    if (item.EnumType == "ActionType")
                                    {
                                        <option value="@item.EnumField">@item.EnumDesc</option>
                                    }
                                }
                            </select>
                        </div>
                        <div class="form-group">
                            <label>OpenID</label>
                            <input type="text" class="form-control" value="@ViewBag.OpenID" style="width:300px;" name="OpenID" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <label>UnionID</label>
                            <input type="text" class="form-control" style="width:100px;" name="UnionID" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <label>创建时间</label>
                            <input type="text" class="form-control" style="width:100px;" name="BTrailDate" id="BTrailDate" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" style="width:100px;" name="ETrailDate" id="ETrailDate" autocomplete="off" />
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="btnSearch">查找</button>
                        </div>

                        <h3 class="box-title"></h3>
                    </form>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    <table class="table table-bordered table-hover body-table-head">
                        <thead>
                            <tr>
                                <th>
                                    主键
                                </th>
                                @*<th>
                                    用户ID
                                </th>*@
                                <th>
                                    浏览标识
                                </th>
                                <th>
                                    浏览类型
                                </th>
                                <th>
                                    操作时间
                                </th>
                                <th>
                                    离开时间
                                </th>
                                <th>
                                    OpenID
                                </th>
                                <th>
                                    UnionID
                                </th>
                                <th>
                                    ActionType
                                </th>
                                <th class="t_c">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody id="tbodylist"></tbody>
                    </table>
                    <div class="no-data" id="nodata" style="display:none;">
                        <div class="img-box"></div>
                        <div class="text">暂无数据</div>
                    </div>
                </div>
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
                <!-- /.box-body -->
                <!-- /.box -->
            </div>
        </div>
    </div>

    <div class="modal fade" id="modal-wechart" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <h4 class="modal-title">Default Modal</h4>
                </div>
                <div class="modal-body">
                    <table class="table table-striped">
                        <tr>
                            <td>姓名</td>
                            <td>Model.UserName</td>
                            <td>电话</td>
                            <td>Model.Mobile</td>
                        </tr>
                        <tr>
                            <td>公司名称</td>
                            <td>Model.CompanyName</td>
                            <td>职位</td>
                            <td>Model.Position</td>
                        </tr>
                        <tr>
                            <td>邮箱</td>
                            <td>Model.Email</td>
                            <td>座机</td>
                            <td>Model.Telephone</td>
                        </tr>
                        <tr>
                            <td>微信号</td>
                            <td>Model.WeChartNum</td>
                            <td>来源渠道</td>
                            <td>Model.UserSence</td>
                        </tr>
                        <tr>
                            <td>地址</td>
                            <td>Model.DAddress</td>
                            <td>创建时间</td>
                            <td>Model.CreateDate</td>
                        </tr>
                        <tr>
                            <td>OpenID</td>
                            <td>Model.OpenID</td>
                            <td>UnionID</td>
                            <td>Model.UnionID</td>
                        </tr>
                        <tr>
                            <td>简介</td>
                            <td colspan="3">Model.UserDesc</td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
</section>
@section scriptsBottom{
    <script src="@Url.Content("~/lib/art-template/template-web.js")"></script>
    <script id="dataItemTpl" type="text/html">
        {{each rows}}
        <tr>
            <td class="title">
                {{$value.WeChartTrailID}}
            </td>
            @*<td class="title">
                {{$value.UserID}}
            </td>*@
            <td class="title">
                {{$value.TrailIdentity}}
            </td>
            <td>
                {{$value.TrailTypeText}}
            </td>
            <td>
                {{$value.TrailDate}}
            </td>
            <td>
                {{$value.AwayDate}}
            </td>
            <td>
                {{$value.OpenID}}
            </td>
            <td>
                {{$value.UnionID}}
            </td>
            <td>
                {{$value.ActionTypeText}}
            </td>
            <td class="t_c">
                <button type="button" class="btn btn-info btn-xs" onclick="detail('{{$value.WeChartTrailID}}')">详情</button>
            </td>
        </tr>
        {{/each}}
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#BCreateDate").datepicker({
                language: "zh-CN",
                autoclose: true,//选中之后自动隐藏日期选择框
                format: "yyyy-mm-dd"//日期格式，
            });
            $("#ECreateDate").datepicker({
                language: "zh-CN",
                autoclose: true,//选中之后自动隐藏日期选择框
                format: "yyyy-mm-dd"//日期格式，
            });

            $("#btnSearch").click(function () {
                pageIndex = 1;
                list();
            });

            list();
        });

        //页码
        var pageIndex = 1;
        //查询
        function list() {
            var fdata = $("#search-form").serializeJson()
            var url = '@Url.Action("List", "WeChartTrail")' + "?page=" + pageIndex;
            //查询列表
            BMCW.ajax({
                url: url,
                type: 'POST',
                dataType: "json",
                data: fdata,
                success: function (dt) {
                    if (dt.total < 1) {
                        $("#nodata").show();
                        document.getElementById('tbodylist').innerHTML = "";
                        return;
                    }
                    $("#nodata").hide();
                    //模板渲染
                    var data = dt.rows;
                    var html = template('dataItemTpl', dt);
                    document.getElementById('tbodylist').innerHTML = html;
                    //分页显示
                    $('#pagination').twbsPagination("destroy");
                    $('#pagination').twbsPagination({
                        totalItems: dt.total,
                        visiblePages: 10,
                        pageSize: 10,
                        startPage: parseInt(pageIndex),
                        onPageClick: function (event, page) {
                            pageIndex = page;
                            list();
                        }
                    });
                }
            });
        }

        //用户详情
        function detail(userid) {
            var url = '@Url.Action("Detail", "WeChartTrail")' + "?userId=" + userid;
            location.href = url;
        }

        //微信信息
        function wechart(openid, nunioid) {
            $("#modal-wechart").modal("show");
        }
    </script>
}
